package com.ruoyi.common.config

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component

/**
 * 读取项目相关配置
 *
 * @author ruoyi
 */
@Component
@ConfigurationProperties(prefix = "ruoyi")
class RuoYiConfig {
    /** 项目名称  */
    var name: String? = null

    /** 版本  */
    var version: String? = null

    /** 版权年份  */
    var copyrightYear: String? = null
    fun setProfile(profile: String?) {
        Companion.profile = profile
    }

    fun setAddressEnabled(addressEnabled: Boolean) {
        isAddressEnabled = addressEnabled
    }

    fun setCaptchaType(captchaType: String?) {
        Companion.captchaType = captchaType
    }

    companion object {
        /** 上传路径  */
        var profile: String? = null
            private set

        /** 获取地址开关  */
        var isAddressEnabled = false
            private set

        /** 验证码类型  */
        var captchaType: String? = null
            private set
        val importPath: String
            /**
             * 获取导入上传路径
             */
            get() = profile.toString() + "/import"
        val avatarPath: String
            /**
             * 获取头像上传路径
             */
            get() = profile.toString() + "/avatar"
        val downloadPath: String
            /**
             * 获取下载路径
             */
            get() = profile.toString() + "/download/"
        val uploadPath: String
            /**
             * 获取上传路径
             */
            get() = profile.toString() + "/upload"
    }
}
